//
//  YLayerDelegate.m
//  yuimall_Iphone
//
//  Created by Gang.Wang on 12-4-26.
//  Copyright (c) 2012年 yuike. All rights reserved.
//

#import "YLayerDelegateProxy.h"
#import <QuartzCore/QuartzCore.h>

@implementation YLayerDelegateProxy
@synthesize view = _view;

- (void) dealloc
{
    [_view release];
    _view = nil;
    [super dealloc];
}

-(id) initWithView: (UIView*) view {
    self = [super init];
    if (self != nil) 
    {
        self.view = view;
    }
    return self;
}

-(void) drawLayer: (CALayer*) layer inContext: (CGContextRef) context {
    NSString* methodName = [NSString stringWithFormat: @"draw%@Layer:inContext:", layer.name];
    SEL selector = NSSelectorFromString(methodName);
    if ([self.view respondsToSelector: selector] == NO)
        selector = @selector(drawLayer:inContext:);
    [self.view performSelector: selector withObject: layer withObject: (id)context];
}

@end
